<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * 我的项目控制类-入口
 * @author liubin-bt
 *@property User_model $User_model
 *@property Project_model $Project_model
 *@property ProjectFollows_model $ProjectFollows_model
 */
class ProjectFollows extends Base {
    
    public function __construct(){
        parent::__construct();
        $this->load->model('ProjectFollows_model');
    }
    
    public function getList(){
        $uid = $this->user['uid'];
        $projects = $this->ProjectFollows_model->getProjectByUid($uid);
        foreach ($projects as &$p){
            $p['label'] = $p['project_name'];
            $p['value'] = $p['id'];
            unset($p['project_name']);
            $p['colorType'] = $p['color_type'];
            unset($p['color_type']);
        }
        log_message('debug', "ProjectFollows.getList \t uid:".$uid." \t request:".json_encode($_REQUEST)." \t res:".json_encode($projects));
        $this->outJsonData(0, $projects);
    }
    
    /**
     * 编辑我的项目
     */
    public function edit(){
        $project_id = intval($this->getSafeRequest('id', ''));
        if( !$project_id ){
            $this->outJsonData(-1, '项目id不能为空');
        }
        $data['color'] = $this->getSafeRequest('color', '');
        $data['color_type'] = $this->getSafeRequest('colorType', '');
        
        $map['project_id'] = $project_id;
        $map['uid'] = $this->user['uid'];
        $res = $this->ProjectFollows_model->update($map, $data);
        $this->outJsonData(0, '编辑成功');
    }
}
?>